//
//  ASHonorCell.m
//  AttendenceSys
//
//  Created by 窦芳俊 on 16/3/30.
//  Copyright © 2016年 窦芳俊. All rights reserved.
//

#import "ASHonorCell.h"

@implementation ASHonorCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier])
    {
        CGFloat fontSize = 16;
        CGFloat padding = 17;
        CGFloat bgWidth = [[UIScreen mainScreen] bounds].size.width;
        
        _honorName = [[UILabel alloc] initWithFrame:CGRectZero];
        _honorName.frame = CGRectMake(padding, 12, bgWidth - 2 * padding, 15);
        [_honorName setBackgroundColor:[UIColor clearColor]];
        [_honorName setTextColor:RGB(51, 51, 51)];
        [_honorName setFont:[UIFont systemFontOfSize:fontSize]];
        [self.contentView addSubview:_honorName];
        
        _honorDepart = [[UILabel alloc] initWithFrame:CGRectZero];
        _honorDepart.frame = CGRectMake(padding, _honorName.frame.origin.y + _honorName.frame.size.height + 5, bgWidth - 2 * padding, 15);
        [_honorDepart setBackgroundColor:[UIColor clearColor]];
        [_honorDepart setTextColor:RGB(51, 51, 51)];
        [_honorDepart setFont:[UIFont systemFontOfSize:fontSize]];
        [self.contentView addSubview:_honorDepart];
        
        _honorLevel = [[UILabel alloc] initWithFrame:CGRectZero];
        _honorLevel.frame = CGRectMake(padding, _honorDepart.frame.origin.y + _honorDepart.frame.size.height + 5, bgWidth - 2 * padding, 15);
        [_honorLevel setBackgroundColor:[UIColor clearColor]];
        [_honorLevel setTextColor:RGB(51, 51, 51)];
        [_honorLevel setFont:[UIFont systemFontOfSize:fontSize]];
        [self.contentView addSubview:_honorLevel];
        
        _honorTime = [[UILabel alloc] initWithFrame:CGRectZero];
        _honorTime.frame = CGRectMake(padding, _honorLevel.frame.origin.y + _honorLevel.frame.size.height + 5, bgWidth - 2 * padding, 15);
        [_honorTime setBackgroundColor:[UIColor clearColor]];
        [_honorTime setTextColor:RGB(51, 51, 51)];
        [_honorTime setFont:[UIFont systemFontOfSize:fontSize]];
        [self.contentView addSubview:_honorTime];
        
        // firstImage
        _firstImage = [[UIImageView alloc] initWithFrame:CGRectZero];
        _firstImage.frame = CGRectMake(padding,
                                       _honorTime.frame.origin.y + _honorTime.frame.size.height + 10,
                                       kHonorImageWidth,
                                       kHonorImageHeight);
        //_firstImage.backgroundColor = [UIColor redColor];
        [self.contentView addSubview:_firstImage];
        
        // secondImage
        _secondImage = [[UIImageView alloc] initWithFrame:CGRectZero];
        _secondImage.frame = CGRectMake(padding * 2 + kHonorImageWidth,
                                        _honorTime.frame.origin.y + _honorTime.frame.size.height + 10,
                                        kHonorImageWidth,
                                        kHonorImageHeight);
        //_secondImage.backgroundColor = [UIColor redColor];
        [self.contentView addSubview:_secondImage];
        
        // thirdImage
        _thirdImage = [[UIImageView alloc] initWithFrame:CGRectZero];
        _thirdImage.frame = CGRectMake(padding * 3 + kHonorImageWidth * 2,
                                       _honorTime.frame.origin.y + _honorTime.frame.size.height + 10,
                                       kHonorImageWidth,
                                       kHonorImageHeight);
        //_thirdImage.backgroundColor = [UIColor redColor];
        [self.contentView addSubview:_thirdImage];
        
        // fourthImage
        _fourthImage = [[UIImageView alloc] initWithFrame:CGRectZero];
        _fourthImage.frame = CGRectMake(padding * 4 + kHonorImageWidth * 3,
                                        _honorTime.frame.origin.y + _honorTime.frame.size.height + 10,
                                        kHonorImageWidth,
                                        kHonorImageHeight);
        //_fourthImage.backgroundColor = [UIColor redColor];
        [self.contentView addSubview:_fourthImage];
        
        // bottom line
        UIImageView* bottomLineView = [[UIImageView alloc] initWithFrame:CGRectMake(padding,
                                                                                    kHonorCellHeight - 1,
                                                                                    bgWidth - padding * 2,
                                                                                    1)];
        [bottomLineView setBackgroundColor:RGB(221, 221, 221)];
        [self.contentView addSubview:bottomLineView];
        
        self.selectionStyle = UITableViewCellSelectionStyleNone;
    }
    
    return self;
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated
{
    [super setSelected:selected animated:animated];
}

- (void)updateHonorCellStaus:(ASHonorInfo *)honorInfo
{
    _honorName.text = honorInfo.honorName;
    _honorLevel.text = honorInfo.honorLevel;
    _honorTime.text = honorInfo.honorTime;
    return;
    
    _honorName.text = @"奖励名称：中国法律研究协会专著发布";   //! 奖励名称
    _honorDepart.text = @"奖励单位：南京师范大学法学院"; //! 奖励单位
    _honorLevel.text = @"奖励级别：国家级别";  //! 奖励级别 (国家级，省级，校级，院级)
    _honorTime.text = @"奖励时间：2016-04-03";   //! 奖励时间
    //_honorImage;  //!
    
    _firstImage.image = [UIImage imageNamed:@"ic_call_activited"];
    _secondImage.image = [UIImage imageNamed:@"ic_call_activited"];
    _thirdImage.image = [UIImage imageNamed:@"ic_call_activited"];
    _fourthImage.image = [UIImage imageNamed:@"ic_call_activited"];
}

@end





